<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<head>
    <title>Reference</title>
    <link rel="stylesheet" href="../ldoc.css" type="text/css" />
</head>
<body>

<div id="container">

<div id="product">
	<div id="product_logo"></div>
	<div id="product_name"><big><b></b></big></div>
	<div id="product_description"></div>
</div> <!-- id="product" -->


<div id="main">


<!-- Menu -->

<div id="navigation">
<br/>
<h1>Duplex</h1>

<ul>
  <li><a href="../index.html">Index</a></li>
</ul>

<h2>Contents</h2>
<ul>
<li><a href="#Functions">Functions</a></li>
<li><a href="#Tables">Tables</a></li>
<li><a href="#Fields">Fields</a></li>
</ul>


<h2>Modules</h2>
<ul class="$(kind=='Topics' and '' or 'nowrap'">
  <li><a href="../modules/Duplex.Application.html">Duplex.Application</a></li>
  <li><a href="../modules/Duplex.Applications.Effect.html">Duplex.Applications.Effect</a></li>
  <li><a href="../modules/Duplex.Applications.GridPie.html">Duplex.Applications.GridPie</a></li>
  <li><a href="../modules/Duplex.Applications.Hydra.html">Duplex.Applications.Hydra</a></li>
  <li><a href="../modules/Duplex.Applications.Instrument.html">Duplex.Applications.Instrument</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.GridLayout.html">Duplex.Applications.Keyboard.GridLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.HarmonicLayout.html">Duplex.Applications.Keyboard.Layouts.HarmonicLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.IsomorphicLayout.html">Duplex.Applications.Keyboard.Layouts.IsomorphicLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.Layouts.PianoLayout.html">Duplex.Applications.Keyboard.Layouts.PianoLayout</a></li>
  <li><a href="../modules/Duplex.Applications.Keyboard.html">Duplex.Applications.Keyboard</a></li>
  <li><a href="../modules/Duplex.Applications.Matrix.html">Duplex.Applications.Matrix</a></li>
  <li><a href="../modules/Duplex.Applications.Metronome.html">Duplex.Applications.Metronome</a></li>
  <li><a href="../modules/Duplex.Applications.MidiActions.Bindings.html">Duplex.Applications.MidiActions.Bindings</a></li>
  <li><a href="../modules/Duplex.Applications.MidiActions.html">Duplex.Applications.MidiActions</a></li>
  <li><a href="../modules/Duplex.Applications.Mixer.html">Duplex.Applications.Mixer</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_group.html">Duplex.Applications.Mlrx.Mlrx_group</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_note.html">Duplex.Applications.Mlrx.Mlrx_note</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_pos.html">Duplex.Applications.Mlrx.Mlrx_pos</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.Mlrx_track.html">Duplex.Applications.Mlrx.Mlrx_track</a></li>
  <li><a href="../modules/Duplex.Applications.Mlrx.html">Duplex.Applications.Mlrx</a></li>
  <li><a href="../modules/Duplex.Applications.Navigator.html">Duplex.Applications.Navigator</a></li>
  <li><a href="../modules/Duplex.Applications.NotesOnWheels.html">Duplex.Applications.NotesOnWheels</a></li>
  <li><a href="../modules/Duplex.Applications.PatternCursor.html">Duplex.Applications.PatternCursor</a></li>
  <li><a href="../modules/Duplex.Applications.PatternSequence.html">Duplex.Applications.PatternSequence</a></li>
  <li><a href="../modules/Duplex.Applications.Recorder.html">Duplex.Applications.Recorder</a></li>
  <li><a href="../modules/Duplex.Applications.Repeater.html">Duplex.Applications.Repeater</a></li>
  <li><a href="../modules/Duplex.Applications.Rotate.html">Duplex.Applications.Rotate</a></li>
  <li><a href="../modules/Duplex.Applications.StepSequencer.html">Duplex.Applications.StepSequencer</a></li>
  <li><a href="../modules/Duplex.Applications.SwitchConfiguration.html">Duplex.Applications.SwitchConfiguration</a></li>
  <li><a href="../modules/Duplex.Applications.TestPad.html">Duplex.Applications.TestPad</a></li>
  <li><a href="../modules/Duplex.Applications.TrackSelector.html">Duplex.Applications.TrackSelector</a></li>
  <li><a href="../modules/Duplex.Applications.Transport.html">Duplex.Applications.Transport</a></li>
  <li><a href="../modules/Duplex.Applications.UIButtonTest.html">Duplex.Applications.UIButtonTest</a></li>
  <li><a href="../modules/Duplex.Applications.XYPad.html">Duplex.Applications.XYPad</a></li>
  <li><a href="../modules/Duplex.Automation.html">Duplex.Automation</a></li>
  <li><a href="../modules/Duplex.Browser.html">Duplex.Browser</a></li>
  <li><a href="../modules/Duplex.BrowserProcess.html">Duplex.BrowserProcess</a></li>
  <li><a href="../modules/Duplex.Canvas.html">Duplex.Canvas</a></li>
  <li><a href="../modules/Duplex.CanvasPoint.html">Duplex.CanvasPoint</a></li>
  <li><a href="../modules/Duplex.ControlMap.html">Duplex.ControlMap</a></li>
  <li><a href="../modules/Duplex.Device.html">Duplex.Device</a></li>
  <li><a href="../modules/Duplex.Display.html">Duplex.Display</a></li>
  <li><a href="../modules/Duplex.Globals.html">Duplex.Globals</a></li>
  <li><a href="../modules/Duplex.Message.html">Duplex.Message</a></li>
  <li><a href="../modules/Duplex.MessageStream.html">Duplex.MessageStream</a></li>
  <li><a href="../modules/Duplex.MidiDevice.html">Duplex.MidiDevice</a></li>
  <li><a href="../modules/Duplex.OscClient.html">Duplex.OscClient</a></li>
  <li><a href="../modules/Duplex.OscDevice.html">Duplex.OscDevice</a></li>
  <li><a href="../modules/Duplex.OscVoiceMgr.html">Duplex.OscVoiceMgr</a></li>
  <li><a href="../modules/Duplex.Preferences.html">Duplex.Preferences</a></li>
  <li><a href="../modules/Duplex.ProcessSlicer.html">Duplex.ProcessSlicer</a></li>
  <li><a href="../modules/Duplex.RoamingDSP.html">Duplex.RoamingDSP</a></li>
  <li><a href="../modules/Duplex.Scheduler.html">Duplex.Scheduler</a></li>
  <li><strong>Duplex.StateController</strong></li>
  <li><a href="../modules/Duplex.UIButton.html">Duplex.UIButton</a></li>
  <li><a href="../modules/Duplex.UIButtonStrip.html">Duplex.UIButtonStrip</a></li>
  <li><a href="../modules/Duplex.UIComponent.html">Duplex.UIComponent</a></li>
  <li><a href="../modules/Duplex.UIKey.html">Duplex.UIKey</a></li>
  <li><a href="../modules/Duplex.UIKeyPressure.html">Duplex.UIKeyPressure</a></li>
  <li><a href="../modules/Duplex.UILabel.html">Duplex.UILabel</a></li>
  <li><a href="../modules/Duplex.UIPad.html">Duplex.UIPad</a></li>
  <li><a href="../modules/Duplex.UIPitchBend.html">Duplex.UIPitchBend</a></li>
  <li><a href="../modules/Duplex.UISlider.html">Duplex.UISlider</a></li>
  <li><a href="../modules/Duplex.UISpinner.html">Duplex.UISpinner</a></li>
  <li><a href="../modules/Duplex.WidgetHooks.html">Duplex.WidgetHooks</a></li>
  <li><a href="../modules/Duplex.WidgetKeyboard.html">Duplex.WidgetKeyboard</a></li>
  <li><a href="../modules/Duplex.html">Duplex</a></li>
  <li><a href="../modules/main.html">main</a></li>
</ul>

</div>

<div id="content">

<h1>Module <code>Duplex.StateController</code></h1>
<p>The StateController handles states within a display/controlmap</p>

<p>A state can toggle any part of a control-map on/off while a device configuration is running.</p>
<p>
<p> They represent a separate mapping layer, independantly of the device configuration, and are especially useful when you are running out of space on the controller - or when an application does not provide you with enough flexibility. </p>

<p>Adding a state is done via the special <Stage> tag - however, a state will not do anything by itself. You still need to associate the state with one or more 'triggers', buttons that share their value with the state. </p>

<p>Once a state has been defined, you can begin prefixing target nodes, using the state's name as the identifier - for example, <MyState:Param></p>

<p>Most nodes can be prefixed: Group, Row, Column and Param (but not SubParam). For a detailed description of all supported attributes for <State> nodes, please refer to the ControlMap class</p>

<h3>Changes</h3>

<p>  0.99.3</p>
<pre><code>- First release
</code></pre>

</p>


<h2><a href="#Functions">Functions</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#__init">__init (display)</a></td>
	<td class="summary">Initialize the StateController class</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#handle_message">handle_message (msg)</a></td>
	<td class="summary">interpret an incoming message, update display accordingly
 (this method is invoked when the MessageStream receive a message)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#add_state">add_state (xarg, t)</a></td>
	<td class="summary">add a state</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#match">match (msg)</a></td>
	<td class="summary">match states with message - discover if message is a trigger</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#initialize">initialize ()</a></td>
	<td class="summary">called once the display has created the virtual control surface</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#add_view">add_view (state_id, view)</a></td>
	<td class="summary">associate a parameter with a named state</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#toggle">toggle (state_id)</a></td>
	<td class="summary">toggle a named state</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#enable">enable (state_id)</a></td>
	<td class="summary">activate a named state</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#disable">disable (state_id)</a></td>
	<td class="summary">deactivate a named state</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#update_trigger">update_trigger (ui_obj, color, text, val)</a></td>
	<td class="summary">update the display of a trigger-button</td>
	</tr>
</table>
<h2><a href="#Tables">Tables</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#self.states">self.states</a></td>
	<td class="summary">
<p>associative array</p>
<pre><code>[string] = {          -- state name/id
  xarg = (table)      -- control-map attributes
  active = (bool)     -- current state
  triggers = [
    param = (table)   -- control-map &lt;Param&gt;
    ui_obj = (table)  -- instance of UIButton
  ],...
</code></pre>
</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.registered_ids">self.registered_ids</a></td>
	<td class="summary">(table) list of control-map elements
 (used when initializing)</td>
	</tr>
</table>
<h2><a href="#Fields">Fields</a></h2>
<table class="function_list">
	<tr>
	<td class="name" nowrap><a href="#self.display">self.display</a></td>
	<td class="summary">(<a href="../modules/Duplex.Display.html#">Duplex.Display</a>)</td>
	</tr>
	<tr>
	<td class="name" nowrap><a href="#self.app">self.app</a></td>
	<td class="summary">(<a href="../modules/Duplex.Application.html#">Duplex.Application</a>)
 handles our trigger-buttons</td>
	</tr>
</table>

<br/>
<br/>


    <h2><a name="Functions"></a>Functions</h2>
    <dl class="function">
    <dt>
    <a name = "__init"></a>
    <strong>__init (display)</strong>
    </dt>
    <dd>
    Initialize the StateController class


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">display</span>



        </li>
    </ul>





</dd>
    <dt>
    <a name = "handle_message"></a>
    <strong>handle_message (msg)</strong>
    </dt>
    <dd>
    interpret an incoming message, update display accordingly
 (this method is invoked when the MessageStream receive a message)


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">msg</span>



        </li>
    </ul>





</dd>
    <dt>
    <a name = "add_state"></a>
    <strong>add_state (xarg, t)</strong>
    </dt>
    <dd>
    add a state


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">xarg</span>



        </li>
        <li><span class="parameter">t</span>



        </li>
    </ul>





</dd>
    <dt>
    <a name = "match"></a>
    <strong>match (msg)</strong>
    </dt>
    <dd>
    match states with message - discover if message is a trigger


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">msg</span>
        TRACE("StateController - match",msg)
        </li>
    </ul>

    <h3>Returns:</h3>
    <ol>

        table
    </ol>




</dd>
    <dt>
    <a name = "initialize"></a>
    <strong>initialize ()</strong>
    </dt>
    <dd>
    called once the display has created the virtual control surface







</dd>
    <dt>
    <a name = "add_view"></a>
    <strong>add_view (state_id, view)</strong>
    </dt>
    <dd>
    associate a parameter with a named state


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">state_id</span>
         (string) unique name/id for the state
        </li>
        <li><span class="parameter">view</span>
         (table) control-map parameter
        </li>
    </ul>





</dd>
    <dt>
    <a name = "toggle"></a>
    <strong>toggle (state_id)</strong>
    </dt>
    <dd>
    toggle a named state


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">state_id</span>
         (string) unique name/id for the state
        </li>
    </ul>





</dd>
    <dt>
    <a name = "enable"></a>
    <strong>enable (state_id)</strong>
    </dt>
    <dd>
    activate a named state


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">state_id</span>
         (string) unique name/id for the state
        </li>
    </ul>





</dd>
    <dt>
    <a name = "disable"></a>
    <strong>disable (state_id)</strong>
    </dt>
    <dd>
    deactivate a named state


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">state_id</span>
         (string) unique name/id for the state
        </li>
    </ul>





</dd>
    <dt>
    <a name = "update_trigger"></a>
    <strong>update_trigger (ui_obj, color, text, val)</strong>
    </dt>
    <dd>
    update the display of a trigger-button


    <h3>Parameters:</h3>
    <ul>
        <li><span class="parameter">ui_obj</span>
         (<a href="../modules/Duplex.UIButton.html#">Duplex.UIButton</a>)
        </li>
        <li><span class="parameter">color</span>
         (table) 8-bit r/g/b values
        </li>
        <li><span class="parameter">text</span>
         (string) button or label text
        </li>
        <li><span class="parameter">val</span>
         (number or table) as defined by the UIComponent
        </li>
    </ul>





</dd>
</dl>
    <h2><a name="Tables"></a>Tables</h2>
    <dl class="function">
    <dt>
    <a name = "self.states"></a>
    <strong>self.states</strong>
    </dt>
    <dd>

<p>associative array</p>
<pre><code>[string] = {          -- state name/id
  xarg = (table)      -- control-map attributes
  active = (bool)     -- current state
  triggers = [
    param = (table)   -- control-map &lt;Param&gt;
    ui_obj = (table)  -- instance of UIButton
  ],...
  params = (table)    -- table of control-map params
    [1] = {
      xarg = (table)
    }
},...
</code></pre>








</dd>
    <dt>
    <a name = "self.registered_ids"></a>
    <strong>self.registered_ids</strong>
    </dt>
    <dd>
    (table) list of control-map elements
 (used when initializing)







</dd>
</dl>
    <h2><a name="Fields"></a>Fields</h2>
    <dl class="function">
    <dt>
    <a name = "self.display"></a>
    <strong>self.display</strong>
    </dt>
    <dd>
    (<a href="../modules/Duplex.Display.html#">Duplex.Display</a>)







</dd>
    <dt>
    <a name = "self.app"></a>
    <strong>self.app</strong>
    </dt>
    <dd>
    (<a href="../modules/Duplex.Application.html#">Duplex.Application</a>)
 handles our trigger-buttons







</dd>
</dl>


</div> <!-- id="content" -->
</div> <!-- id="main" -->
<div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.2</a></i>
</div> <!-- id="about" -->
</div> <!-- id="container" -->
</body>
</html>
